# 3.28 Environment Monitoring ## 3.28.1 Overview In this project, we use an OLED display to reveal the values of temperature, humidity, air pressure and altitude in the environment. It can be regarded as a mini environmental monitoring device. ## 3.28.2 Test Code ### 3.28.2.1 Build Code There are two ways to upload the code: directly open the code file we provide; or manually build blocks. **Directly open the code file we provide:** 1. Click ![](./media/j68.png) and choose `Load from your computer` ![](./media/j67.png) 2. We have already downloaded the codes on computer desktop, so open the file and choose `3-28-environmentalMonitoring.sb3` **Manually build blocks:** 1. Build the two basic blocks:![6-1-4-1-1](./media/6-1-4-1-1.png) 2. Add a BMP388 and OLED initialization block; Add a string block to set its parameters. ![QQ_1721803712158](./media/6-28-2-1-1.png) 3. Read BMP388 module value, and display “Data Sugges” in the center of the first line of OLED. Centered: set cursor to x=30 (the starting cursors vary with strings). ![QQ_1721804274756](./media/6-28-2-1-2.png) 4. Set the starting position of displayed values (Y from 10: the height of the first line). Add 3 OLED display blocks and set the display of the first two to "no-warp", set the first line of code to display "T:" (indicating temperature) The second line shows the temperature value. The third line shows "C" (temperature in degrees Celsius) and print in "warp" mode. ![QQ_1721804842582](./media/6-28-2-1-3.png). 5. Duplicate ![QQ_1721805190266](./media/6-28-2-1-4.png) and modify the content in the first line into “RH:(humidity value)”; The second line will show the humidity value. The third line shows the unit of the value “%”. ![QQ_1721805400589](./media/6-28-2-1-5.png) 6. Duplicate ![QQ_1721805428061](./media/6-28-2-1-6.png) and modify the content in the first line into “P:(pressure)”, The second line will show the value. The third line shows the unit of the value “hPa”. ![QQ_1721805463843](./media/6-28-2-1-7.png) 7. Duplicate ![QQ_1721805619055](./media/6-28-2-1-8.png) and modify the content in the first line into “ASL:(altitude value)”, The second line will show the value. The third line shows the unit of the value “M”(meter). Add a OLED refresh block and add a delay of 1s. ![QQ_1721805906991](./media/6-28-2-1-9.png) **Complete Test Code** ![6-28-2-2](./media/6-28-2-2.png) ### 3.28.2.2 Test Result After uploading code, you will see the values of temperature, humidity, air pressure and altitude on the OLED display. ![6-28-2-2-1](./media/6-28-2-2-1.png)